<?php
if( empty( $_SESSION ) )
{
	session_start();
}
header("Content-Type: text/html; charset=utf-8",true);

include_once("../../includes/restrito.php");
include_once("../models/cls.edicao.php");

$oEdicao = new edicao();
switch( isset( $_GET["acao"] ) )
{
	
	case "editar" :
		$oEdicao->select( $_GET["id"] );
		break;		
}

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>EDIÇÃO</title>
<link rel="stylesheet" type="text/css" href="../../includes/sistema.css"/>
<script type="text/javascript" src="../../includes/jquery.js"></script>
<script type="text/javascript" src="../../includes/jquery.mask.js"></script>
<script>
jQuery(function($){
	$("#ano").mask("999");
	$("#data").mask("99/99/9999");
})

function _salvar(){
	if(document.frm.id_idioma.value=="")
	{
		alert("Por favor, informe o idioma desta edição!");
		document.frm.id_idioma.focus();
		return;
	}
	if(document.frm.ano.value=="")
	{
		alert("Por favor, informe o ano desta edição!");
		document.frm.ano.focus();
		return;
	}
	if(document.frm.numero.value=="")
	{
		alert("Por favor, informe o número desta edição!");
		document.frm.numero.focus();
		return;
	}
	if(document.frm.data.value=="")
	{
		alert("Por favor, informe a data desta edição!");
		document.frm.data.focus();
		return;
	}
	if(document.frm.nome.value=="")
	{
		alert("Por favor, informe o título desta edição!");
		document.frm.nome.focus();
		return;
	}
	document.frm.submit();
}
</script>
</head>
<body>
<div id="content">
    <h2>Edição</h2>
    <hr size="1" noshade="noshade">
    	<form name="frm" method="post" action="../controllers/ctl.edicao.php">
        
          <table width="600" border="0" align="center">
            <tr>
              <td width="5%">Ano: </td>
              <td width="5%">Número:</td>
              <td width="5%">Data:</td>
              <td width="60%" align="left">Idioma:</td>
            </tr>
            <tr>
              <td width="5%"><input id="ano" name="ano" type="text" class="form25px" value="<?php echo $oEdicao->ano; ?>" maxlength="3" /></td>
              <td width="5%"><input id="numero" name="numero" type="text" class="form70px" value="<?php echo $oEdicao->numero; ?>" /></td>
              <td width="5%"><input id="data" name="data" type="text" class="form70px" value="<?php echo $oEdicao->formatar_data($oEdicao->data,'get'); ?>" /></td>
              <td width="25%" align="left"><select name="id_idioma" class="form100pc">
                <?php echo $oEdicao->select_idioma(); ?>
              </select></td>
            </tr>
            <tr>
              <td colspan="5">Título:
              <input name="nome" type="text" class="form100pc" value="<?php echo $oEdicao->nome; ?>" /></td>
            </tr>
            <tr>
              <td colspan="5">
              <input type="hidden" name="id" value="<?php echo $oEdicao->id; ?>" />
              <input type="hidden" name="publicar" value="<?php echo $oEdicao->publicar; ?>" />
              <input type="hidden" name="especial" value="<?php echo $oEdicao->especial; ?>" />
              <input type="button" name="btnSalvar" value="SALVAR" class="formButton" onClick="_salvar()" />
              <input name="btnVoltar" type="button" class="formButton" value="VOLTAR" onclick="javascript:history.back();" />
              </td>
            </tr>
          </table>
    	</form>
</div>
</body>
</html>